package com.interview.one.controller;

import com.interview.one.common.CommonRes;
import com.qiniu.util.Auth;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/common")
public class UploadController {
    @PostMapping("/getUploadToken")
    public CommonRes getUploadToken() {
        String accessKey = "mCBgiNnVijIUsqQuOS-1KVC5chTq08P-iMoyzjo_";
        String secretKey = "x3imiDXDFuqnA8Uwd4Y2bG4ISdZpIeU_C8aZursv";
        String bucket = "kotlin";
        Auth auth = Auth.create(accessKey, secretKey);
        String upToken = auth.uploadToken(bucket);
        System.out.println(upToken);
        return CommonRes.create(upToken);
    }
}
